// 数字人管理——任务列表
import request from '@/utils/request';
import {object2Url} from "@/utils/trans";


/*任务列表刷新接口*/
export async function digitalDataRefresh(data) {
  const res = await request.post('/business/imageTask/refreshData', data);
  if (res.data.code === 2000) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.msg));
}



/*查看数字人任务列表总数量*/
export async function queryAllTaskCount(data) {
  const res = await request.post('/business/imageTask/pageLists', data);
  if (res.data.code === 2000) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.msg));
}

/*查看任务列表分页*/
export async function queryTaskPage(data) {
  const res = await request.post('/business/imageTask/pageList', data);
  if (res.data.code === 2000) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.msg));
}

/*删除任务列表分页*/
export async function delTask(data) {
  const res = await request.post('/business/imageTask/delete', data);
  if (res.data.code === 2000) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.msg));
}

/*查询任务列表——数据统计*/
export async function queryDyksCount(data) {
  const res = await request.post('/business/imageTask/dyksCount', data);
  if (res.data.code === 2000) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.msg));
}


/*查询任务列表——数据统计总数据，单个字段返回*/
export async function queryAllCount(data) {
  const res = await request.post('/business/imageTask/dyksCounts', data);
  if (res.data.code === 2000) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.msg));
}





/*查询详情*/
export async function queryTaskDetail(data) {
  const res = await request.post('/business/imageTask/page', data);
  if (res.data.code === 2000) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.msg));
}

// 表格——发布作品接口
export async function finishTask(data) {
  const res = await request.post('/business/szrRelease/createTask', data);
  if (res.data.code === 2000) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.msg));
}



// 视频号发布生成二维码
/*export async function sphIssue(data) {
  const res = await request.post('/business/szrRelease/sphQrIssue', data);
  if (res.data.code === 2000) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.msg));
}*/
export async function sphIssue(parms) {
  const ts = new Date().getTime();
  const ua = navigator.userAgent;
  const us = {
    cookie:parms.cookie,
    releaseId:parms.releaseId

  };
  // ${object2Url(us)} get 链接传值
  let url = `/business/szrRelease/sphQrIssue${object2Url(us)}`
  const res = await request.get(url, us);
  if (res.data.code === 2000) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.msg));
}



// 抖音h5发布生成二维码——未使用
export async function getDyCode(merchantId) {
  const ts = new Date().getTime();
  const ua = navigator.userAgent;
  const us = {
    releaseId:1,
    merchantId: merchantId  // 商家id

  };
  // ${object2Url(us)} get 链接传值
  let url = `/business/szrRelease/douyin/open/auth/h5${object2Url(us)}`
  const res = await request.get(url, us);
  if (res.data.code === 2000) {
    return res.data;
  }
  return Promise.reject(new Error(res.data.msg));
}


// 抖音h5发布生成二维码——使用
export async function getDyH5Code(id) {
  const ts = new Date().getTime();
  const ua = navigator.userAgent;
  const us = {
    releaseId:id
  };
  // ${object2Url(us)} get 链接传值
  let url = `/business/szrRelease/h5QrCode${object2Url(us)}`
  const res = await request.get(url, us);
  if (res.data.code === 200) {
    return res.data;
  }
  return Promise.reject(new Error(res.data.msg));
}


// 快手发布生成二维码
export async function getKsCode(id) {
  const ts = new Date().getTime();
  const ua = navigator.userAgent;
  const us = {
    releaseId:id
  };
  // ${object2Url(us)} get 链接传值
  let url = `/business/szrRelease/kuaishou/open/auth/code${object2Url(us)}`
  const res = await request.get(url, us);
  if (res.data.code === 2000) {
    return res.data;
  }
  return Promise.reject(new Error(res.data.msg));
}

/*export async function getKsCode(data) {
  const res = await request.post('/business/szrRelease/kuaishou/open/auth/code', data);
  if (res.data.code === 2000) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.msg));
}*/

